package com.cat.greedyAlgorithm;

import java.io.*;

/**
 * @author 曲大人的喵
 * @description https://ac.nowcoder.com/acm/contest/119225/B
 * @create 2025/10/12 19:04
 * @since JDK17
 */

public class Solution87 {
    static int N = ((int) (1e9 + 7)), n, m;


    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StreamTokenizer in = new StreamTokenizer(br);
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        // 接收输入
        in.nextToken();
        n = ((int) in.nval);
        long x, y;
        in.nextToken();
        x = ((long) in.nval);
        in.nextToken();
        y = ((long) in.nval);
        for (int i = 1; i < n; i++) {
            long t1, t2, a = x, b = y;
            in.nextToken();
            t1 = ((long) in.nval);
            in.nextToken();
            t2 = ((long) in.nval);
            x = (a * t1 - b * t2) % N;
            y = (a * t2 + b * t1) % N;
        }
        out.println((x + N) % N + " " + (y + N) % N);

        br.close();
        out.flush();
        out.close();
    }
}
